// JavaScript Document
/*
Author:Anil
*/
var branchSelected=new Array();
var courseSelected=new Array();
var branchtocourse=new function(){
	$(document).ready(function(){
							   
							   $("select[name='selectedBranchs']").multiSelect({
																			   
																			   afterSelect:function(values){
															   branchSelected.push(values);
															  },
															  afterDeselect: function(values){
    branchSelected.pop(values);
  },
											selectableHeader: "<div class='custom-header'>Selectable branch(s)</div>",
  											selectionHeader: "<div class='custom-header'>Selection branch(s)</div>"});
							    
							      $("select[name='selectedCourses']").multiSelect({
																				  
																				    afterSelect:function(values){
															   courseSelected.push(values);
															  },
															  afterDeselect: function(values){
    courseSelected.pop(values);
  },
											selectableHeader: "<div class='custom-header'>Selectable course(s)</div>",
  											selectionHeader: "<div class='custom-header'>Selection course(s)</div>"  
																				  });
							   
							   
							   
							   });
	
	this.saveupdate=function(){
		  
		  if(branchSelected.length==0){
			  validation.errorMsg("Select branch",$("select[name='selectedBranchs']"));
			  return;
			  }
			  if(courseSelected.length==0){
			  validation.errorMsg("Select course",$("select[name='selectedCourses']"));
			  return;
			  }
		validation.saveUpdate("s_u_branchtocourse.action","branchCourseDetails");
		}
	
	
	this.clearForm=function(){
		 branchSelected=new Array();
 courseSelected=new Array();
		 $("select[name='selectedBranchs']").multiSelect("deselect_all");
		 $("select[name='selectedCourses']").multiSelect("deselect_all");
		}
	
	}